//! \file url.hpp
//! \brief Purewell Library URL Encoder/Decoder Header
//! \author Yubin Lim (purewell@gmail.com)
//! \since 2008-08-01

#ifndef __PWHDR_URL_HPP__
#define __PWHDR_URL_HPP__

namespace purewell
{

//! \brief URL encoder/decoer
class PWAPI PWUrl
{
public:
	//! \brief Encode stream.
	//! \param[out] os Output stream.
	//! \param[in] is Input stream.
	//! \return Output stream reference.
	std::ostream& encode(std::ostream& os, std::istream& is) const;

	//! \brief Encode block.
	//! \param[out] obuf Output buffer. It's would be 3 times of input
	//! buffer length.
	//! \param[in] ibuf Input buffer.
	//! \param[in] iblen Input buffer length.
	//! \return Output buffer length.
	size_t encode(char* obuf, const char* ibuf, size_t iblen) const;

	//! \brief Decode stream.
	//! \param[out] os Output stream.
	//! \param[in] is Input stream.
	//! \return Output stream reference.
	std::ostream& decode(std::ostream& os, std::istream& is) const;

	//! \brief Decode block.
	//! \param[out] obuf Output buffer.
	//! \param[in] ibuf Input buffer.
	//! \param[in] iblen Input buffer length.
	//! \return Output buffer length.
	size_t decode(char* obuf, const char* ibuf, size_t iblen) const;

public:
	//! \brief Get instance.
	//! \return Instance reference.
	static PWUrl& getInstance(void);

private:
	explicit PWUrl();
	inline PWUrl& operator = (const PWUrl&) { return *this; }

};//class PWUrl

//! \brief Global URL encoder/decoder instance.
extern PWAPI PWUrl& gPWUrl;

};//namespace purewell

#endif//!__PWHDR_URLCODE_HPP__

